package whf.file.entity;

import whf.framework.entity.Permissionable;
import whf.framework.entity.TreeNode;
import whf.framework.security.entity.Permission;

/**
 * @author wanghaifeng
 * @create Mar 28, 2007 9:32:48 PM
 * 
 */
public class Folder extends whf.framework.entity.AbstractEntity implements TreeNode<Folder>, Permissionable, whf.framework.file.IFolder {

	private static final long serialVersionUID = 0;

	private whf.file.entity.Folder parent;
	
	private Permission permission;
	// ---------- methods ----------

	public void setParent(whf.file.entity.Folder parent) {
		this.parent = parent;
	}

	public whf.file.entity.Folder getParent() {
		return this.parent;
	}

	/**
	 * @return Returns the permission.
	 */
	public Permission getPermission() {
		return permission;
	}

	/**
	 * @param permission The permission to set.
	 */
	public void setPermission(Permission permission) {
		this.permission = permission;
	}

	/* (non-Javadoc)
	 * @see whf.framework.file.IFolder#getParentFolder()
	 */
	public whf.framework.file.IFolder getParentFolder() {
		return this.parent;
	}

	public String getPath() {
		if(this.getParent() != null) {
			return this.getParent().getId() + System.getProperty("file.separator") + this.getId() + System.getProperty("file.separator");
		} else {
			return String.valueOf(this.getId()) + System.getProperty("file.separator");
		}
	}
}